package net.zjitc.common;


public class ServiceResp<T> {
    private int state;//状态
    private String message;//消息
    private T data;//数据

    public ServiceResp(int state) {
        this.state = state;
    }

    public ServiceResp(int state, String message) {
        this.state = state;
        this.message = message;
    }

    public ServiceResp(int state, T data) {
        this.state = state;
        this.data = data;
    }

    public ServiceResp(int state, String message, T data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }

    public int getState() {
        return state;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }

    public static <T> ServiceResp createSuccessState(){
        return new ServiceResp<>(RespCode.SUCCESS.getState());
    }
    public static <T> ServiceResp createSuccessMessage(String msg){
        return new ServiceResp<>(RespCode.SUCCESS.getState(),msg);
    }
    public static <T> ServiceResp createBySuccess(T data){
        return new ServiceResp<>(RespCode.SUCCESS.getState(),data);
    }
    public static <T> ServiceResp createBySuccess(String msg, T data){
        return new ServiceResp<>(RespCode.SUCCESS.getState(),msg,data);
    }
    public static <T> ServiceResp createERRORState(){
        return new ServiceResp<>(RespCode.ERROR.getState());
    }
    public static <T> ServiceResp createERRORMessage(String msg){
        return new ServiceResp<>(RespCode.ERROR.getState(),msg);
    }
    public static <T> ServiceResp createByERROR(T data){
        return new ServiceResp<>(RespCode.ERROR.getState(),data);
    }
    public static <T> ServiceResp createByERROR(String msg, T data){
        return new ServiceResp<>(RespCode.ERROR.getState(),msg,data);
    }
}
